﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace InstaMe.DB
{
    public delegate void DBCompleteDelegate(QueryObject aDBObject);
    public delegate void DBErrorDelegate(QueryObject aDBObject);

    public class IDBListener
    {
        private DBCompleteDelegate mDBComplete;
        private DBErrorDelegate mDBError;

        public IDBListener()
        {
            mDBComplete = null;
            mDBError = null;
        }

        public void setDBCompleteDelegate(DBCompleteDelegate aCompleteDelegate)
        {
            mDBComplete = aCompleteDelegate;
        }

        public void setDBErrorDelegate(DBErrorDelegate aErrorDelegate)
        {
            mDBError = aErrorDelegate;
        }

        public void OnDBComplete(QueryObject aDBObject)
        {
            if (mDBComplete != null)
            {
                mDBComplete(aDBObject);
            }
        }

        public void OnDBError(QueryObject aDBObject)
        {
            if (mDBError != null)
            {
                mDBError(aDBObject);
            }
        }
    }
}
